#include "head.h"

void *find (arr *a, int coord_length, int coord_hight) {
	if ((coord_length>=0) && (coord_length<a->length) && (coord_hight>=0) && (coord_length<a->hight)) {
		return (((char*)a->start)+coord_length*a->size+coord_hight*a->size);
	} else {
		return 0;
	}
}

void recreate (int hight, int length, arr *a, int siz) {
	void *p;
	arr b;
	b.start=new(&_arr,hight,length,siz);
	if (b.size==a->size) {
		copy_paste(&b,a,0,0);
		p=a->start;
		a->hight=b.hight;
		a->hight=b.length;
		a->start=b.start;
		a->size=b.size;
		b.start=p;
		delete(&b);
	}
}

void copy_paste (arr *a, arr *b, int pos_1, int pos_2) {
	int i, j;
	for (i=0; i<(a->length-pos_1); i++) {
		for (j=0;j<(a->hight-pos_2);j++) {
			a[pos_1+i, pos_2+j]=b[i,j];
		}
	}
}

